{% load static %}
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>{{ printable.title|default:"ClassWeaver Printable Pack" }}</title>
    <link rel="stylesheet" href="{% static 'print.css' %}" />
  </head>
  <body class="printable">
    <header>
      <h1>{{ printable.title|default:"ClassWeaver Printable Pack" }}</h1>
    </header>

    <section>
      <h2>Knowledge Points</h2>
      <ul>
        {% for kp in printable.knowledge_points %}
          <li>
            <strong>{{ kp.title|default:kp.id }}</strong>
            <p>{{ kp.summary }}</p>
          </li>
        {% empty %}
          <li>No knowledge points available.</li>
        {% endfor %}
      </ul>
    </section>

    <section>
      <h2>Glossary</h2>
      <dl>
        {% for item in printable.glossary %}
          <dt>{{ item.term }}</dt>
          <dd>{{ item.definition }}</dd>
        {% empty %}
          <dt>No glossary terms.</dt>
        {% endfor %}
      </dl>
    </section>

    <section>
      <h2>Quiz</h2>
      {% for item in printable.quiz %}
        <article class="quiz-item">
          <header>
            <span class="qid">Q{{ forloop.counter }}</span>
            <h3>{{ item.question }}</h3>
          </header>
          <ul>
            {% for option_key, option_value in item.options.items %}
              <li>{{ option_key }}. {{ option_value }}</li>
            {% endfor %}
          </ul>
          {% if item.answer %}
            <p class="answer">Answer: {{ item.answer }} — {{ item.explain }}</p>
          {% endif %}
        </article>
      {% empty %}
        <p>No quiz items available.</p>
      {% endfor %}
    </section>

    <section>
      <h2>Practice</h2>
      <ol>
        {% for practice in printable.practice %}
          <li>
            <p>{{ practice.prompt }}</p>
            {% if practice.answer %}
              <p class="answer">Suggested answer: {{ practice.answer }}</p>
            {% endif %}
            {% if practice.reasoning %}
              <p class="explain">{{ practice.reasoning }}</p>
            {% endif %}
          </li>
        {% empty %}
          <li>No extra practice generated.</li>
        {% endfor %}
      </ol>
    </section>
  </body>
</html>
